package zip;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author liuwj3
 *
 */
public class TestTryWithResource {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        try (FileInputStream in = new FileInputStream("D://123.doc");
            FileOutputStream out = new FileOutputStream("D://kwfy.doc")) {
            byte[] b = new byte[2 * 1024 * 1024];
            int index;
            while ((index = in.read(b, 0, b.length)) != -1) {
                out.write(b, 0, index);
                out.flush();
            }
        }
    }

}
